package com.gr.analys;
import java.io.IOException;
import java.io.Reader;
import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.analysis.StopFilter;
import org.apache.lucene.analysis.TokenStream;
import org.apache.lucene.analysis.Tokenizer;

public class VietAnalyzer1 extends Analyzer{
	 @Override
	    public TokenStream tokenStream(String string, Reader reader) {
	            ViTokenizer1 tokenStream=null;
	            try {
	        //        System.out.println(">>>>>>>>>>>Creating new _VTokenizer.....");
	                tokenStream = new ViTokenizer1(reader);
	            } catch (Exception ex) {
	          //      System.out.println("Loi ko tach tu duoc!");
	                ex.printStackTrace();
	            }
                    setPreviousTokenStream(tokenStream);
                    return tokenStream;
	    }

	  @Override
	  public TokenStream reusableTokenStream(String fieldName, Reader reader) throws IOException {
	 //    System.out.println(">>>>>>>>>>>>ReusableTokenStream method.................>>>");
	    Tokenizer tokenizer = (Tokenizer) getPreviousTokenStream();
	    if (tokenizer == null) {
	      tokenizer = new ViTokenizer1(reader);
	      setPreviousTokenStream(tokenizer);
	      //Filter here
	      //TODO
	    } else              
                tokenizer.reset(reader);
	    return tokenizer;
	  }
}
